home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / umddvi / lib / strsave.c < prev    next >
C/C++ Source or Header  |  1990-10-01  |  522b  |  26 lines

  1. /*
  2.  * Copyright (c) 1987 University of Maryland Department of Computer Science.
  3.  * All rights reserved.  Permission to copy for any purpose is hereby granted
  4.  * so long as this copyright notice remains intact.
  5.  */
  6.  
  7. /*
  8.  * Save a string in managed memory.
  9.  */
  10.  
  11. char    *malloc(), *realloc();
  12. extern int errno;
  13.  
  14. char *
  15. strsave(s)
  16.     register char *s;
  17. {
  18.     register int l = strlen(s) + 1;
  19.     register char *p = malloc((unsigned) l);
  20.  
  21.     if (p == 0)
  22.         error(1, errno, "no room for %d bytes of string", l);
  23.     bcopy(s, p, l);
  24.     return (p);
  25. }
  26.